/*
 * Copyright (C) 2025 Tsingteng MicroSystem
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 * @file rw_utils.h
 * @brief 读卡模块相关的工具函数定义
 */

#ifndef _RW_UTILS_H_
#define _RW_UTILS_H_

#include "nci_feature.h"
#if IS_FEATURE_ON(NCI_FEATURE_RW)

#include "rw_tag.h"

/**
 * @brief 通过激活参数创建tag
 *
 * @param p_params 激活参数
 *
 * @return 创建成功返回tag指针，失败返回NULL
 */
tNCI_RW_TAG *rw_utils_create_tag(tNCI_RF_INTF_ACTIVATED_PARAMS *p_params);
/**
 * @brief 从NCI_RF_INTF_ACTIVATED_PARAMS中获取tag类型并添加到p_tag中
 *
 * @param p_tag 需要被添加的tag指针
 * @param p_params 需要被添加的激活参数
 *
 * @return 成功返回NCI_STATUS_OK，失败返回其他值
 */
tNCI_STATUS rw_utils_add_tech(tNCI_RW_TAG *p_tag, tNCI_RF_INTF_ACTIVATED_PARAMS *p_params);
/**
 * @brief dump tag信息
 *
 * @param p_tag tag指针
 * @param fd 文件描述符
 */
void rw_utils_dump_tag(int fd, const tNCI_RW_TAG *p_tag);
/**
 * @brief 通过协议获取rf接口
 *
 * @param protocol 协议类型
 *
 * @return 返回rf接口类型
 */
tNCI_RF_INTERFACE rw_utils_get_rf_interface_from_protocol(tNCI_RF_PROTOCOL protocol);
/**
 * @brief 获取tag对应的操作api
 *
 * @param p_tag tag指针
 *
 * @return 当当前tag协议类型不支持时返回NULL，否则返回对应的tag操作api
 */
tNCI_RW_TAG_API* rw_utils_get_tag_api(tNCI_RW_TAG *p_tag);
/**
 * @brief 计算x的log2
 */
uint32_t rw_utils_tags_log2(uint32_t x);

#endif // IS_FEATURE_ON(NCI_FEATURE_RW)

#endif /* _RW_UTILS_H_ */
